package com.han.nettytestdemo.connector;


import com.han.nettytestdemo.connector.communication.ProductCallback;
import com.han.nettytestdemo.connector.impl.ImsImpl;

import io.netty.util.internal.StringUtil;

/**
 * Created by bayi on 2016/4/15.
 */
public class TreadReadGetImsState {

    private static final String TAG = TreadReadGetImsState.class.getSimpleName();

    private ImsStateListener imsStateListener;

    public ImsStateListener getImsStateListener() {
        return imsStateListener;
    }

    public void setImsStateListener(ImsStateListener imsStateListener) {
        this.imsStateListener = imsStateListener;
    }

    private String leftData = "";//左侧数据
    private String rightData = "";//右侧数据

    public TreadReadGetImsState() {
    }

    ImsConnector imsConnector = new ImsImpl();


    ProductCallback productCallback1 = (state, age) -> {

        LogUtil.d(TAG, "左侧架体状态：" + state + "  架体数据：" + age);
        if (state == ProductCallback.Sur) {
            try {
                if (imsStateListener != null) {
                    imsStateListener.onImsState(age);
                }

            } catch (Exception e) {
                e.printStackTrace();
            }
        } else {
        }
    };

    /**
     * 开始执行
     */
    public void startRun() {
        try {
            imsConnector.leftContinuousVentilation(Command.GET_R_VENTILATION, productCallback1);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
